#include "CEnemyType3.h"
#include "MainLayer.h"

CEnemyType3::CEnemyType3(CEnemyParams enemyParams) : CEnemy(enemyParams)
{
}

void
CEnemyType3::createBoxBodyForSize(CEnemyParams::EEnemySize size)
{
	CEnemy::createBoxBody();

	switch(size)
	{
	case CEnemyParams::size1:
		createBoxBodySize1();
		break;
	case CEnemyParams::size2:
		createBoxBodySize2();
		break;
	case CEnemyParams::size3:
		createBoxBodySize3();
		break;
	case CEnemyParams::size4:
		createBoxBodySize4();
		break;
	default:
		break;
	}
}

void
CEnemyType3::createBoxBodySize1()
{
    b2BodyDef spriteBodyDef;
    spriteBodyDef.type = b2_dynamicBody;
    spriteBodyDef.active = true;
    float x = this->getPosition().x / P2M;
    float y = this->getPosition().y / P2M;
    spriteBodyDef.position.Set(x, y);
    spriteBodyDef.userData = this;
    _pBody = _pWorld->CreateBody(&spriteBodyDef);

    b2CircleShape spriteShape;
    spriteShape.m_radius = 26.8f / P2M;
    spriteShape.m_p = b2Vec2(0.0, 0.0f);
    b2FixtureDef spriteShapeDef;
    spriteShapeDef.shape = &spriteShape;
    spriteShapeDef.density = 1.0;
    spriteShapeDef.restitution = 0.5f;
	spriteShapeDef.filter.categoryBits = ECategoryBit::enemyCategoryBit;
	spriteShapeDef.filter.maskBits = ECategoryBit::bulletCategoryBit |
									  ECategoryBit::shipCategoryBit |
									  ECategoryBit::shieldCategoryBit;

    _pBody->CreateFixture(&spriteShapeDef);

}

void
CEnemyType3::createBoxBodySize2()
{
    b2BodyDef spriteBodyDef;
    spriteBodyDef.type = b2_dynamicBody;
    spriteBodyDef.active = true;
    float x = this->getPosition().x / P2M;
    float y = this->getPosition().y / P2M;
    spriteBodyDef.position.Set(x, y);
    spriteBodyDef.userData = this;
    _pBody = _pWorld->CreateBody(&spriteBodyDef);

    b2CircleShape spriteShape;
    spriteShape.m_radius = 33.5f / P2M;
    spriteShape.m_p = b2Vec2(0.0, 0.0f);
    b2FixtureDef spriteShapeDef;
    spriteShapeDef.shape = &spriteShape;
    spriteShapeDef.density = 1.0;
    spriteShapeDef.restitution = 0.5f;
	spriteShapeDef.filter.categoryBits = ECategoryBit::enemyCategoryBit;
	spriteShapeDef.filter.maskBits = ECategoryBit::bulletCategoryBit |
									  ECategoryBit::shipCategoryBit |
									  ECategoryBit::shieldCategoryBit;

    _pBody->CreateFixture(&spriteShapeDef);

}

void
CEnemyType3::createBoxBodySize3()
{
    b2BodyDef spriteBodyDef;
    spriteBodyDef.type = b2_dynamicBody;
    spriteBodyDef.active = true;
    float x = this->getPosition().x / P2M;
    float y = this->getPosition().y / P2M;
    spriteBodyDef.position.Set(x, y);
    spriteBodyDef.userData = this;
    _pBody = _pWorld->CreateBody(&spriteBodyDef);

    b2CircleShape spriteShape;
    spriteShape.m_radius = 41.2f / P2M;
    spriteShape.m_p = b2Vec2(0.0, 0.0f);
    b2FixtureDef spriteShapeDef;
    spriteShapeDef.shape = &spriteShape;
    spriteShapeDef.density = 1.0;
    spriteShapeDef.restitution = 0.5f;
	spriteShapeDef.filter.categoryBits = ECategoryBit::enemyCategoryBit;
	spriteShapeDef.filter.maskBits = ECategoryBit::bulletCategoryBit |
									  ECategoryBit::shipCategoryBit |
									  ECategoryBit::shieldCategoryBit;

    _pBody->CreateFixture(&spriteShapeDef);

}

void
CEnemyType3::createBoxBodySize4()
{
    b2BodyDef spriteBodyDef;
    spriteBodyDef.type = b2_dynamicBody;
    spriteBodyDef.active = true;
    float x = this->getPosition().x / P2M;
    float y = this->getPosition().y / P2M;
    spriteBodyDef.position.Set(x, y);
    spriteBodyDef.userData = this;
    _pBody = _pWorld->CreateBody(&spriteBodyDef);

    b2CircleShape spriteShape;
    spriteShape.m_radius = 48.0f / P2M;
    spriteShape.m_p = b2Vec2(0.0, 0.0f);
    b2FixtureDef spriteShapeDef;
    spriteShapeDef.shape = &spriteShape;
    spriteShapeDef.density = 1.0;
    spriteShapeDef.restitution = 0.5f;
	spriteShapeDef.filter.categoryBits = ECategoryBit::enemyCategoryBit;
	spriteShapeDef.filter.maskBits = ECategoryBit::bulletCategoryBit |
									  ECategoryBit::shipCategoryBit |
									  ECategoryBit::shieldCategoryBit;

    _pBody->CreateFixture(&spriteShapeDef);

}
